Toriality's Blog

java_operators

created_at:

June 4, 2024 at 5:40 PM

last_updated:

July 15, 2024 at 8:11 PM

Operators

Operator Precedence

  1. Postfix: expr++, expr--
  2. Unary: ++expr, --expr, +expr, -expr, ~, !
  3. Multiplicative: *, /, %
  4. Additive: +, -
  5. Shift: <<, >>, >>>
  6. Relational: <, >, <=, >=, instanceof
  7. Equality: ==, !=
  8. Bitwise AND: &
  9. Bitwise XOR: ^
  10. Bitwise OR: |
  11. Logical AND: &&
  12. Logical OR: ||
  13. Ternary: ?:
  14. Assignment: =, +=, -=, *=, /=, %=, <<=, >>=, >>>=, &=, ^=, |=

instanceof

The instanceof operator compares an object to a specified type. You can use it to test if an object is an instance of a class, an instance of a subclass, or an instance of a class that implements an interface.

When using the 'instanceof' operator, keep in mind that 'null' is not an instance of anything.